import request from '@/utils/request'
import { ObjectType, ResponseDataPromise } from 'typings/interfaces'
import * as proxy from '@/constants/proxy'

/**
 * 获取机构树
 * @param depth 层数
 * @returns RecordsResponse
 */
export const fetchOrgTree = (depth: number): ResponseDataPromise<ObjectType> =>
  request({
    url: proxy.CHECC_API_CMS + '/org/tree/by-unit-type',
    method: 'get',
    params: { depth },
  })


// 根据当前用户获取机构树
export const fetchUserOrgTree = (orgId: number): ResponseDataPromise<ObjectType> =>
  request({
    url: proxy.CHECC_API_CMS + 'org/getSubordinateIds',
    method: 'get',
    params: { orgId },
  })
